package com.ruoyi.service.production.impl;

import com.ruoyi.domain.production.MesProductionPickingDetail;
import com.ruoyi.mapper.production.MesProductionPickingDetailMapper;
import com.ruoyi.service.production.IMesProductionPickingDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 生产领料单明细Service业务层处理
 * 
 * @author ruoyi
 */
@Service
public class MesProductionPickingDetailServiceImpl implements IMesProductionPickingDetailService
{
    @Autowired
    private MesProductionPickingDetailMapper mesProductionPickingDetailMapper;

    /**
     * 查询生产领料单明细
     * 
     * @param detailId 生产领料单明细主键
     * @return 生产领料单明细
     */
    @Override
    public MesProductionPickingDetail selectMesProductionPickingDetailByDetailId(Long detailId)
    {
        return mesProductionPickingDetailMapper.selectMesProductionPickingDetailByDetailId(detailId);
    }

    /**
     * 查询生产领料单明细列表
     * 
     * @param mesProductionPickingDetail 生产领料单明细
     * @return 生产领料单明细
     */
    @Override
    public List<MesProductionPickingDetail> selectMesProductionPickingDetailList(MesProductionPickingDetail mesProductionPickingDetail)
    {
        return mesProductionPickingDetailMapper.selectMesProductionPickingDetailList(mesProductionPickingDetail);
    }

    /**
     * 根据领料单ID查询明细列表
     * 
     * @param pickingId 领料单ID
     * @return 明细集合
     */
    @Override
    public List<MesProductionPickingDetail> selectDetailListByPickingId(Long pickingId)
    {
        return mesProductionPickingDetailMapper.selectDetailListByPickingId(pickingId);
    }

    /**
     * 根据物料ID查询领料明细
     * 
     * @param materialId 物料ID
     * @return 明细集合
     */
    @Override
    public List<MesProductionPickingDetail> selectDetailListByMaterialId(Long materialId)
    {
        return mesProductionPickingDetailMapper.selectDetailListByMaterialId(materialId);
    }

    /**
     * 根据批次号查询领料明细
     * 
     * @param batchNumber 批次号
     * @return 明细集合
     */
    @Override
    public List<MesProductionPickingDetail> selectDetailListByBatchNumber(String batchNumber)
    {
        return mesProductionPickingDetailMapper.selectDetailListByBatchNumber(batchNumber);
    }

    /**
     * 新增生产领料单明细
     * 
     * @param mesProductionPickingDetail 生产领料单明细
     * @return 结果
     */
    @Override
    public int insertMesProductionPickingDetail(MesProductionPickingDetail mesProductionPickingDetail)
    {
        return mesProductionPickingDetailMapper.insertMesProductionPickingDetail(mesProductionPickingDetail);
    }

    /**
     * 修改生产领料单明细
     * 
     * @param mesProductionPickingDetail 生产领料单明细
     * @return 结果
     */
    @Override
    public int updateMesProductionPickingDetail(MesProductionPickingDetail mesProductionPickingDetail)
    {
        return mesProductionPickingDetailMapper.updateMesProductionPickingDetail(mesProductionPickingDetail);
    }

    /**
     * 批量删除生产领料单明细
     * 
     * @param detailIds 需要删除的生产领料单明细主键
     * @return 结果
     */
    @Override
    public int deleteMesProductionPickingDetailByDetailIds(Long[] detailIds)
    {
        return mesProductionPickingDetailMapper.deleteMesProductionPickingDetailByDetailIds(detailIds);
    }

    /**
     * 删除生产领料单明细信息
     * 
     * @param detailId 生产领料单明细主键
     * @return 结果
     */
    @Override
    public int deleteMesProductionPickingDetailByDetailId(Long detailId)
    {
        return mesProductionPickingDetailMapper.deleteMesProductionPickingDetailByDetailId(detailId);
    }

    /**
     * 批量新增生产领料单明细
     * 
     * @param detailList 生产领料单明细列表
     * @return 结果
     */
    @Override
    public int batchInsertMesProductionPickingDetail(List<MesProductionPickingDetail> detailList) {
        if (detailList == null || detailList.isEmpty()) {
            return 0;
        }
        int result = 0;
        for (MesProductionPickingDetail detail : detailList) {
            result += mesProductionPickingDetailMapper.insertMesProductionPickingDetail(detail);
        }
        return result;
    }

    /**
     * 根据领料单ID删除明细
     * 
     * @param pickingId 领料单ID
     * @return 结果
     */
    @Override
    public int deleteMesProductionPickingDetailByPickingId(Long pickingId) {
        return mesProductionPickingDetailMapper.deleteMesProductionPickingDetailByPickingId(pickingId);
    }
}